package com.cdxy.controller;

import com.cdxy.biz.process.IRegsBizProcess;
import com.cdxy.model.dto.base.controller.BaseController;
import com.cdxy.model.dto.base.resp.ApiResponse;
import com.cdxy.model.dto.req.RegsEmailCodeReq;
import com.cdxy.model.dto.req.SendEmailCodeReq;
import com.cdxy.model.dto.req.RegsMobileCodeReq;
import com.cdxy.model.dto.req.SendMobileCodeReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: tangy
 * @Date: 2020/3/17 10:29
 */
@RestController
@Api(value = "用户注册", tags = "用户注册")
public class RegsController extends BaseController {

    @Autowired
    private IRegsBizProcess regsBizProcess;

    @PostMapping("/sendRegsSms")
    @ApiOperation(value = "注册）发送手机验证码", notes = "")
    public ApiResponse sendRegsSms(@Validated @RequestBody SendMobileCodeReq sendMobileCodeReq) {
        regsBizProcess.regsSendSms(sendMobileCodeReq);
        return successApiResponse();
    }

    @PostMapping("/sendRegsEmail")
    @ApiOperation(value = "注册）发送邮箱验证码", notes = "")
    public ApiResponse sendRegsEmail(@Validated @RequestBody SendEmailCodeReq sendEmailCodeReq) {
        regsBizProcess.regsSendEmail(sendEmailCodeReq);
        return successApiResponse();
    }

    @PostMapping("/regsMobileCode")
    @ApiOperation(value = "手机验证码注册", notes = "")
    public ApiResponse regsByMobileCode(@Validated @RequestBody RegsMobileCodeReq regsMobileCodeReq) {
        regsBizProcess.regsByMobileCode(regsMobileCodeReq);
        return successApiResponse();
    }

    @PostMapping("/regsEmailCode")
    @ApiOperation(value = "邮箱验证码注册", notes = "")
    public ApiResponse regsByEmailCode(@Validated @RequestBody RegsEmailCodeReq regsMobileCodeReq) {
        regsBizProcess.regsByEmailCode(regsMobileCodeReq);
        return successApiResponse();
    }
}
